#!/usr/bin/env python
''' This class is the ds to store the PerM's mapping output line'''
class PerMMappingLineInfo( object ):
    ''' DS for PerM's output info with member variable
        read_name, read, isoform, location, strand, mis
    '''
    def __init__( self, line ):
        line = line.strip()
        info = line.split( "\t" )
        MIN_RECORD_USED = 7
        if len( info ) >= MIN_RECORD_USED:
            try:
                self.read_name = info[0]
                self.read = info[1]
                self.isoform_name = info[2]
                self.location = int( info[3] )
                #self.ref = info[4]
                self.strand = info[5]
                self.mis = info[6]
            except ValueError:
                print self.read_name + " mapped to " + self.isoform_name
                print "has wrong value"
                print info[3]
        else:
            if not line.strip() == "":
                print line # add fake data to avoid crash
                print "\n is not in a correct format\n"
            self.read_name = "fake_read"
            self.read = "AAA"
            self.isoform_name = "fake_isoform"
            self.location = 0
            #self.ref = info[4]
            self.strand = '+'
            self.mis = 0

